home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
3 PutContentsIn Igor Pro Folder
/
Technical Notes
/
Igor Tech Notes
/
TN006 DSP support
/
DFT TEXT
< prev
next >
Wrap
Text File
|
1994-06-03
|
3KB
|
103 lines
| Given a complex input wave and a same size output wave, calculate the
| Discrete Fourier Transform using the direct (slow) method.
| parameter dir should be +1 for forward transform or -1 for reverse.
| input wave is not changed
|
| The x scaling of the output wave should be changed by the caller
| with a statement such as
| Setscale/p x,0,1/numpnts(inw)/(pnt2x(inw,1)-pnt2x(inw,0)), outw
|
| Requires: DFT1()
|
Function DFT(inw,outw,dir)
wave/c inw,outw
variable dir
variable n=numpnts(inw)
variable nn
variable dx= pnt2x(inw,1)-pnt2x(inw,0)
nn=0
do
outw[nn]= DFT1(inw,dir,nn/(n*dx))
nn+=1
while(nn<n)
return 0
end
| Given a complex input wave and a complex output wave (probably of different size),
| calculate the Discrete Fourier Transform using the direct (slow) method for the frequencies
| in the range of fMin to fMax, inclusive. outw[0] will contain the value for fMin, and outw[n-1]
| will contain the value for fMax.
| parameter dir should be +1 for forward transform or -1 for reverse.
| input wave is not changed.
|
| The x scaling of the output wave should be changed by the caller
| with a statement such as
| Setscale/I x, fMin,fMax, outw
| The values of the output wave have the normal multiplication factor of inPts=numpnts(inw);
| if the input wave is a record of repetitive data, divide outwave by inPts.
|
| Requires: DFT1()
|
Function DFTVarRes(inw,outw,fMin,fMax,dir) | Do transform between fMin and fMax
wave/c inw,outw
variable fMin,fMax,dir
variable n=numpnts(outw)
variable freq
variable nn
nn=0
do
freq= fMin+nn/(n-1)*(fMax-fMin)
outw[nn]= DFT1(inw,dir,freq)
nn+=1
while(nn<n)
return 0
end
| Given a complex input wave and a same size output wave, calculate the
| Discrete Fourier Transform using the direct (slow) method.
| parameter dir should be +1 for forward transform or -1 for reverse.
| input wave is not changed
| parameter freq is the frequency at which the forward DFT will be computed,
| it is the time at which the inverse DFT is computed.
| Returns complex value of Discrete Fourier Transform at given frequency (forward)
| or time (backward)
|
Function/C DFT1(inw,dir,freq)
wave/c inw
variable dir,freq
variable n=numpnts(inw)
variable/c w,wrot
variable kk
variable dx= pnt2x(inw,1)-pnt2x(inw,0)
variable pointFreq= freq*dx |pointFreq varies from 0 to 1. 0 for Constant Term, 1 for max frequency term (it plays role of nn/n in DFT Function)
Variable/C out=0
kk=0
w= cmplx(1,0)
wrot= cmplx(cos(2*pi*pointFreq),sin(2*pi*pointFreq)) | was wrot= cmplx(cos(2*pi*nn/n),sin(2*pi*nn/n)) in DFT()
if(dir== -1)
wrot= conj(wrot)
endif
do
out += inw[kk]*w
w *= wrot
kk+=1
while(kk<n)
if(dir== -1)
out /= n
endif
return out
end